<template>
  <div>
    <Child2 v-if="flag"></Child2>
    <Child1></Child1>
    <button @click="flag=true">显示组件2</button>
  </div>
</template>

<script>
//import Child1 from '@/views/Child1.vue'
//import Child2 from '@/views/Child2.vue'

export default {
  data(){
    return{
      flag:false
    }
  },
  components:{
    Child1:()=>import('@/views/Child1.vue'),
    Child2:()=>import('@/views/Child2.vue'),
    //Child1,Child2
  
  }
}
</script>

<style>

</style>